package com.gmail.fanvaron.Listener;

import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.SignChangeEvent;

import com.gmail.fanvaron.Main.MarvMonsterPack;
import com.gmail.fanvaron.Utils.Utils;

public class BlockListener implements Listener {

	public MarvMonsterPack plugin;

	public BlockListener(MarvMonsterPack instance) {
		plugin = instance;
	}

	@EventHandler(priority = EventPriority.HIGHEST)
	public void onSignChange(SignChangeEvent event) {
		if ((event.isCancelled()) || (event.getPlayer() == null)) {
			return;
		}
		if (event.getLines()[0].equalsIgnoreCase(Utils.INFINITE)) {

			if (event.getPlayer().hasPermission("infinitdisp.signs")) {
				event.getPlayer().sendMessage(ChatColor.WHITE + "Unendlich Schild eingerichtet / Infinite Sign activated");
				return;
			} else {

				event.getPlayer().sendMessage(
						"Unendliche Spender und Werfer, nur als "
								+ ChatColor.DARK_RED + "VIP");
				event.getPlayer().sendMessage(
						ChatColor.DARK_GREEN + "Jetzt " + ChatColor.DARK_RED
								+ "VIP" + ChatColor.DARK_GREEN
								+ " werden, mehr Infos unter " + ChatColor.GOLD
								+ "/vip");
				event.setCancelled(true);
			}
		}

	}
}
